package db.pojo;

import java.util.*;
import java.text.SimpleDateFormat;
import db.ext.EacodeExt;
@SuppressWarnings("unchecked")
/**
 * eacode
 */
public class Eacode {
	/**
	 * CODEID
	 */
	public String cODEID;
	/**
	 * FIELD
	 */
	public String fIELD;
	/**
	 * FIELDNAME
	 */
	public String fIELDNAME;
	/**
	 * CODE
	 */
	public String cODE;
	/**
	 * CODEDESC
	 */
	public String cODEDESC;
	/**
	 * ENABLED
	 */
	public String eNABLED;
	/**
	 * EDITMODE
	 */
	public String eDITMODE;
	/**
	 * SORTNO
	 */
	public int sORTNO;
	/**
	 * REMARK
	 */
	public String rEMARK;
	SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public static EacodeExt DB = new EacodeExt(); 
	
	public Eacode() {
		super();
	}
	
	public Eacode(String cODEID, String fIELD, String fIELDNAME, String cODE, String cODEDESC, String eNABLED, String eDITMODE, int sORTNO, String rEMARK) {
		super();
		this.cODEID = cODEID; 
		this.fIELD = fIELD; 
		this.fIELDNAME = fIELDNAME; 
		this.cODE = cODE; 
		this.cODEDESC = cODEDESC; 
		this.eNABLED = eNABLED; 
		this.eDITMODE = eDITMODE; 
		this.sORTNO = sORTNO; 
		this.rEMARK = rEMARK; 
	}
	
	public String getCODEID() {
		return cODEID;
	}

	public void setCODEID(String cODEID) {
		this.cODEID = cODEID;
	} 
	
	public String getFIELD() {
		return fIELD;
	}

	public void setFIELD(String fIELD) {
		this.fIELD = fIELD;
	} 
	
	public String getFIELDNAME() {
		return fIELDNAME;
	}

	public void setFIELDNAME(String fIELDNAME) {
		this.fIELDNAME = fIELDNAME;
	} 
	
	public String getCODE() {
		return cODE;
	}

	public void setCODE(String cODE) {
		this.cODE = cODE;
	} 
	
	public String getCODEDESC() {
		return cODEDESC;
	}

	public void setCODEDESC(String cODEDESC) {
		this.cODEDESC = cODEDESC;
	} 
	
	public String getENABLED() {
		return eNABLED;
	}

	public void setENABLED(String eNABLED) {
		this.eNABLED = eNABLED;
	} 
	
	public String getEDITMODE() {
		return eDITMODE;
	}

	public void setEDITMODE(String eDITMODE) {
		this.eDITMODE = eDITMODE;
	} 
	
	public int getSORTNO() {
		return sORTNO;
	}

	public void setSORTNO(int sORTNO) {
		this.sORTNO = sORTNO;
	} 
	
	public void changeSORTNOWith(int sORTNO){
		this.sORTNO += sORTNO;
	}
	
	public void changeSORTNOWithMin(int sORTNO,int min){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO < min ? min : this.sORTNO;
	}
	
	public void changeSORTNOWithMax(int sORTNO,int max){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO > max ? max : this.sORTNO;
	}
	
	public void changeSORTNOWithMaxMin(int sORTNO,int max,int min){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO < min ? min : this.sORTNO;
		this.sORTNO = this.sORTNO > max ? max : this.sORTNO;
	}	
	public String getREMARK() {
		return rEMARK;
	}

	public void setREMARK(String rEMARK) {
		this.rEMARK = rEMARK;
	} 
	
	
	public Map eacodeToMap() {
		Map map = new HashMap();
		try {
			map.put("cODEID",this.cODEID);
			map.put("fIELD",this.fIELD);
			map.put("fIELDNAME",this.fIELDNAME);
			map.put("cODE",this.cODE);
			map.put("cODEDESC",this.cODEDESC);
			map.put("eNABLED",this.eNABLED);
			map.put("eDITMODE",this.eDITMODE);
			map.put("sORTNO",this.sORTNO);
			map.put("rEMARK",this.rEMARK);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

	public Eacode mapToEacode(Map map){
		try {
			String cODEID =  map.get("cODEID").toString();
			String fIELD =  map.get("fIELD").toString();
			String fIELDNAME =  map.get("fIELDNAME").toString();
			String cODE =  map.get("cODE").toString();
			String cODEDESC =  map.get("cODEDESC").toString();
			String eNABLED =  map.get("eNABLED").toString();
			String eDITMODE =  map.get("eDITMODE").toString();
			int sORTNO = Integer.parseInt( map.get("sORTNO").toString());
			String rEMARK =  map.get("rEMARK").toString();
			Eacode eacode = new Eacode(cODEID, fIELD, fIELDNAME, cODE, cODEDESC, eNABLED, eDITMODE, sORTNO, rEMARK);
			return eacode;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	} 
	
	public String toString(){
		return eacodeToMap().toString();
	}
	
	//方便数据操作	
	public Eacode insert(){
		return DB.insert(this);
	}
	public Eacode update(){
		return DB.update(this);
	}
	
	public int delete(){
		return DB.delete(this);
	}
	
}
